#pragma once

#include <ros/message_traits.h>
#include <ros/serialization.h>

#include "@PROTO_H@.pb.h"

namespace ros {
// Begin:@Package@::@Class@
namespace message_traits {
    template <>
    struct MD5Sum<@Package@::@Class@> {
        static const char* value() {
            return "@Checksum@";
        }
        static const char* value(@Package@::@Class@ const& o) {
            return value();
        }
    };

    template <>
    struct DataType<@Package@::@Class@> {
        static const char* value() {
            return "@Package@/@Class@";
        }
        static const char* value(@Package@::@Class@ const& o) {
            return value();
        }
    };

    template <>
    struct Definition<@Package@::@Class@> {
        static const char* value() {
            return "@Package@/@Class@";
        }
        static const char* value(@Package@::@Class@ const& o) {
            return value();
        }
    };
}  // namespace message_traits

namespace serialization {
    template <>
    struct Serializer<@Package@::@Class@> {
        template <typename Stream>
        inline static void write(Stream& stream, const @Package@::@Class@& o) {
            std::string ser_bytes;
            if (!o.SerializeToString(&ser_bytes)) {
                std::cerr << "Serialization failed[@Package@::@Class@]" << std::endl;
                return;
            }
            uint32_t length = static_cast<uint32_t>(ser_bytes.size());
            memcpy(stream.advance(4), &length, 4);
            memcpy(stream.advance(ser_bytes.size()), ser_bytes.c_str(), ser_bytes.size());
        }

        template <typename Stream>
        inline static void read(Stream &stream, @Package@::@Class@ &o) {
            uint32_t length;
            memcpy(&length, stream.advance(4), 4);
            std::string deser_bytes;
            deser_bytes.resize(length);
            memcpy(&deser_bytes[0], stream.advance(length), length);
            if (!o.ParseFromString(deser_bytes)) {
                std::cerr << "Deserialization failed[@Package@::@Class@]" << std::endl;
                return;
            }
        }

        inline static uint32_t serializedLength(const @Package@::@Class@& o) {
            return sizeof(uint32_t) + o.ByteSizeLong();
        }
    };
}  // namespace serialization
// End:@Package@::@Class@
}